home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3c / inet.z / inet
Encoding:
Text File  |  2002-10-03  |  13.2 KB  |  265 lines

  1.  
  2.  
  3.  
  4. IIIINNNNEEEETTTT((((3333NNNN))))                                                              IIIINNNNEEEETTTT((((3333NNNN))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      inet_aton, inet_addr, inet_network, inet_isaddr, inet_ntoa, inet_ntop,
  10.      inet_pton, inet_makeaddr, inet_lnaof, inet_netof - Internet address
  11.      manipulation routines
  12.  
  13. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  14.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttyyyyppppeeeessss....hhhh>>>>
  15.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ssssoooocccckkkkeeeetttt....hhhh>>>>
  16.      ####iiiinnnncccclllluuuuddddeeee <<<<nnnneeeettttiiiinnnneeeetttt////iiiinnnn....hhhh>>>>
  17.      ####iiiinnnncccclllluuuuddddeeee <<<<aaaarrrrppppaaaa////iiiinnnneeeetttt....hhhh>>>>
  18.  
  19.      iiiinnnntttt iiiinnnneeeetttt____aaaattttoooonnnn((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ccccpppp,,,, ssssttttrrrruuuucccctttt iiiinnnn____aaaaddddddddrrrr ****ppppiiiinnnn))));;;;
  20.  
  21.      uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg iiiinnnneeeetttt____aaaaddddddddrrrr((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ccccpppp))));;;;
  22.  
  23.      uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg iiiinnnneeeetttt____nnnneeeettttwwwwoooorrrrkkkk((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ccccpppp))));;;;
  24.  
  25.      iiiinnnntttt iiiinnnneeeetttt____iiiissssaaaaddddddddrrrr((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ccccpppp,,,, uuuuiiiinnnntttt33332222____tttt ****aaaaddddddddrrrr))));;;;
  26.  
  27.      cccchhhhaaaarrrr ****iiiinnnneeeetttt____nnnnttttooooaaaa((((ssssttttrrrruuuucccctttt iiiinnnn____aaaaddddddddrrrr iiiinnnn))));;;;
  28.  
  29.      ccccoooonnnnsssstttt cccchhhhaaaarrrr ****iiiinnnneeeetttt____nnnnttttoooopppp((((iiiinnnntttt aaaaffff,,,, ccccoooonnnnsssstttt vvvvooooiiiidddd ****ssssrrrrcccc,,,, cccchhhhaaaarrrr ****ddddsssstttt,,,, ssssoooocccckkkklllleeeennnn____tttt ssssiiiizzzzeeee))));;;;
  30.  
  31.      iiiinnnntttt iiiinnnneeeetttt____ppppttttoooonnnn((((iiiinnnntttt aaaaffff,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ssssrrrrcccc,,,, vvvvooooiiiidddd ****ddddsssstttt))));;;;
  32.  
  33.      ssssttttrrrruuuucccctttt iiiinnnn____aaaaddddddddrrrr iiiinnnneeeetttt____mmmmaaaakkkkeeeeaaaaddddddddrrrr((((iiiinnnntttt nnnneeeetttt,,,, iiiinnnntttt llllnnnnaaaa))));;;;
  34.  
  35.      uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg iiiinnnneeeetttt____llllnnnnaaaaooooffff((((ssssttttrrrruuuucccctttt iiiinnnn____aaaaddddddddrrrr iiiinnnn))));;;;
  36.  
  37.      uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg iiiinnnneeeetttt____nnnneeeettttooooffff((((ssssttttrrrruuuucccctttt iiiinnnn____aaaaddddddddrrrr iiiinnnn))));;;;
  38.  
  39. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  40.      The routines _i_n_e_t__a_t_o_n, _i_n_e_t__a_d_d_r and _i_n_e_t__n_e_t_w_o_r_k interpret character
  41.      strings representing numbers expressed in the Internet standard "." (dot)
  42.      notation.
  43.  
  44.      The _i_n_e_t__p_t_o_n function converts a presentation format address (that is,
  45.      printable form as held in a character string) to network format (usually
  46.      a _s_t_r_u_c_t _i_n__a_d_d_r or some other internal binary representation, in network
  47.      byte order).  The function returns 1 if the address is valid or 0 if it
  48.      could not be parsed for the given address family.  If the _a_f argument is
  49.      unknown, then -1 is returned with eeeerrrrrrrrnnnnoooo set to EAFNOSUPPORT.  This
  50.      function is presently valid for AF_INET and AF_INET6.  The following
  51.      discussion under INTERNET ADDRESSES is not valid for the function
  52.      iiiinnnneeeetttt____ppppttttoooonnnn , because if its _a_f argument is AF_INET then the _s_r_c string can
  53.      be only in the standard IPv4 dotted decimal form:
  54.  
  55.           ddd.ddd.ddd.ddd
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. IIIINNNNEEEETTTT((((3333NNNN))))                                                              IIIINNNNEEEETTTT((((3333NNNN))))
  71.  
  72.  
  73.  
  74.      where 'ddd' is a one to three digit decimal number between 0 and 255 (see
  75.      the inet_addr() definition).  The iiiinnnneeeetttt____ppppttttoooonnnn () function does not accept
  76.      other formats (such as the octal numbers, hexadecimal numbers, and fewer
  77.      than four numbers that iiiinnnneeeetttt____aaaattttoooonnnn () or iiiinnnneeeetttt____aaaaddddddddrrrr () accepts).  This is a
  78.      narrower input set than that accepted by iiiinnnneeeetttt____aaaattttoooonnnn....
  79.  
  80.      If the af argument of iiiinnnneeeetttt____ppppttttoooonnnn () is AF_INET6, the _s_r_c string must be in
  81.      one of the following standard IPv6 text forms:
  82.  
  83.      1.   The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the
  84.           hexadecimal values of the eight 16-bit pieces of the address.
  85.           Leading zeros in individual fields can be omitted, but there must be
  86.           at least one  numeral in every field.
  87.  
  88.      2.   A string of contiguous zero fields in the preferred form can be
  89.           shown as "::".  The "::" can only appear once in an address.
  90.           Unspecified addresses (0:0:0:0:0:0:0:0) may be represented simply as
  91.           "::".
  92.  
  93.      3.   A third form that is sometimes more convenient when dealing with a
  94.           mixed environment of IPv4 and IPv6 nodes is x:x:x:x:x:x:d.d.d.d,
  95.           where the "x"s are the hexadecimal values of the six high-order 16-
  96.           bit pieces of the address, and the "d"s are the decimal values of
  97.           the four low-order 8-bit pieces of the address (standard IPv4
  98.           representation).
  99.  
  100.      The _i_n_e_t__a_t_o_n routine interprets the specified character string as an
  101.      Internet address, placing the address into the structure provided.  It
  102.      returns 1 if the string was successfully interpreted, or 0 if the string
  103.      is invalid.  The _i_n_e_t__a_d_d_r and _i_n_e_t__n_e_t_w_o_r_k functions return numbers
  104.      suitable for use as Internet addresses and Internet network numbers,
  105.      respectively.
  106.  
  107.      The function _i_n_e_t__n_t_o_p converts an address from network format (usually a
  108.      _s_t_r_u_c_t _i_n__a_d_d_r or some other binary form, in network byte order) to
  109.      presentation format (suitable for external display purposes).  It returns
  110.      NULL if a system error occurs (in which case, _e_r_r_n_o will have been set),
  111.      or it returns a pointer to the destination string.  The _a_f argument
  112.      specifies the family of the address.  This can be AF_INET or AF_INET6.
  113.      The _s_r_c argument points to a buffer holding an IPv4 address if the _a_f
  114.      argument is AF_INET, or an IPv6 address if the _a_f argument is AF_INET6.
  115.      The _d_s_t argument points to a buffer where the function will store the
  116.      resulting text string; it must not be NULL.  The _s_i_z_e argument specifies
  117.      the size of this buffer, which must be large enough to hold the text
  118.      string(INET_ADDRSTRLEN characters for IPv4, INET6_ADDRSTRLEN characters
  119.      for IPv6).
  120.  
  121.      To determine if an ASCII string is a valid representation of an IPv4
  122.      address, the function _i_n_e_t__i_s_a_d_d_r may be used.  It takes a pointer to the
  123.      string, cp, and returns a 1 if the address is valid, 0 otherwise.
  124.      Additionally, if the addr parameter is non-NULL, the converted address
  125.      will be stored at the address pointed to by addr.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. IIIINNNNEEEETTTT((((3333NNNN))))                                                              IIIINNNNEEEETTTT((((3333NNNN))))
  137.  
  138.  
  139.  
  140.      The routine _i_n_e_t__n_t_o_a takes an Internet address and returns an ASCII
  141.      string representing the address in "." notation.  The routine
  142.      _i_n_e_t__m_a_k_e_a_d_d_r takes an Internet network number and a local network
  143.      address and constructs an Internet address from it.  The routines
  144.      _i_n_e_t__n_e_t_o_f and _i_n_e_t__l_n_a_o_f break apart Internet host addresses, returning
  145.      the network number and local network address part, respectively.
  146.  
  147.      All Internet addresses are returned in network order (bytes ordered from
  148.      left to right).  All network numbers and local address parts are returned
  149.      as machine format integer values.
  150.  
  151. IIIINNNNTTTTEEEERRRRNNNNEEEETTTT AAAADDDDDDDDRRRREEEESSSSSSSSEEEESSSS
  152.      Values specified using the "." notation take one of the following forms:
  153.           a.b.c.d
  154.           a.b.c
  155.           a.b
  156.           a
  157.      When four parts are specified, each is interpreted as a byte of data and
  158.      assigned, from left to right, to the four bytes of an Internet address.
  159.  
  160.      When a three part address is specified, the last part is interpreted as a
  161.      16-bit quantity and placed in the right most two bytes of the network
  162.      address.  This makes the three part address format convenient for
  163.      specifying Class B network addresses as "128.net.host".
  164.  
  165.      When a two part address is supplied, the last part is interpreted as a
  166.      24-bit quantity and placed in the right most three bytes of the network
  167.      address.  This makes the two part address format convenient for
  168.      specifying Class A network addresses as "net.host".
  169.  
  170.      When only one part is given, the value is stored directly in the network
  171.      address without any byte rearrangement.
  172.  
  173.      All numbers supplied as "parts" in a "." notation may be decimal, octal,
  174.      or hexadecimal, as specified in the C language (i.e., a leading 0x or 0X
  175.      implies hexadecimal; otherwise, a leading 0 implies octal; otherwise, the
  176.      number is interpreted as decimal).
  177.  
  178. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  179.      The constant IIIINNNNAAAADDDDDDDDRRRR____NNNNOOOONNNNEEEE is returned by _i_n_e_t__a_d_d_r and _i_n_e_t__n_e_t_w_o_r_k for
  180.      malformed requests.
  181.  
  182. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  183.      gethostbyname(3N), getnetent(3N), hosts(4), networks(4)
  184.  
  185. SSSSTTTTAAAANNNNDDDDAAAARRRRDDDDSSSS
  186.      The iiiinnnneeeetttt____nnnnttttoooopppp and iiiinnnneeeetttt____ppppttttoooonnnn functions conform to XNS 5.2 standards.
  187.  
  188. BBBBUUUUGGGGSSSS
  189.      The value IIIINNNNAAAADDDDDDDDRRRR____NNNNOOOONNNNEEEE (0xffffffff) is a valid broadcast address, but
  190.      _i_n_e_t__a_d_d_r cannot return that value without indicating failure.  The newer
  191.      _i_n_e_t__a_t_o_n function does not share this problem.
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. IIIINNNNEEEETTTT((((3333NNNN))))                                                              IIIINNNNEEEETTTT((((3333NNNN))))
  203.  
  204.  
  205.  
  206.      The string returned by _i_n_e_t__n_t_o_a resides in a static memory area.  Thus
  207.  
  208.           printf("%s %s0, inet_ntoa(addr1), inet_ntoa(addr2));
  209.  
  210.      will print the same address twice.
  211.  
  212.      Inet_addr should return a struct in_addr.
  213.  
  214.      The problem of host byte ordering versus network byte ordering is
  215.      confusing.
  216.  
  217.      A simple way to specify Class C network addresses in a manner similar to
  218.      that for Class B and Class A is needed.
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.